package cn.bellychang.loopqueue.arraylist.cl02fixedcapacity;

import cn.bellychang.iiterface.bobo.Queue;

/**
 * FIFO  head array[0]  tail array[getSize]
 * @author: bellychang
 * @date: 2020/2/8
 */
public class LoopQueue<E> implements Queue<E> {

    private ArrayList<E> arrayList;

    public LoopQueue() {
        arrayList = new ArrayList<>(1);
    }

    public int getCapacity() {
        return arrayList.getCapacity();
    }

    @Override
    public int getSize() {
        return arrayList.getSize();
    }

    @Override
    public boolean isEmpty() {
        return arrayList.getSize()==0;
    }

    @Override
    public void enqueue(E e) {
        arrayList.addLast(e);
    }

    @Override
    public E dequeue() {
        return arrayList.removeFirst();
    }

    @Override
    public E getFront() {
        return arrayList.getFront();
    }

    @Override
    public String toString() {
        return "ArrayQueue Head {" + arrayList + "} Tail";
    }
}
